package cn.xiaopengstack.types.framework.strategy.link.singleton;

/**
 * @author jiangyangang
 */
public abstract class AbstractLogicLink<T, D, R> implements ILogicLink<T, D, R>{

    private ILogicLink<T, D, R> next;

    @Override
    public ILogicLink<T, D, R> next() {
        return next;
    }

    @Override
    public ILogicLink<T, D, R> appendNext(ILogicLink<T, D, R> next) {
        this.next = next;
        return next;
    }

    /**
     * 执行链
     * @param request
     * @param dynamic
     * @return
     * @throws Exception
     */
    protected R execute(T request, D dynamic) throws Exception{
        return next.apply(request, dynamic);
    }
}
